package main

import (
	"fmt"
)

type myInt int //自定义类型

type yourInt = int //类型别名

func main() {
	var n myInt
	fmt.Printf("%T\n", n)
	var m yourInt
	m = 100
	fmt.Printf("%T\n", m)

	//结构体初始化
	var zhangsan person
	zhangsan.name = "张三"
	zhangsan.age = 18
	zhangsan.gender = "男"
	zhangsan.body = []string{"头", "脚", "手", "腿"}
	fmt.Println(zhangsan)
	//值类型结构体初始化
	var p person1
	p.name = "李四"
	p.gender = "女"
	f1(p)
	fmt.Println(p)
	f2(&p)
	fmt.Println(p)
	//值列表初始化
	var p1 = person{
		name:   "王五",
		age:    20,
		gender: "男",
		body:   []string{"头", "脚", "手", "腿"},
	}
	fmt.Println(p1)
}

//结构体

type person struct {
	name   string
	age    int
	gender string
	body   []string
}

//匿名结构体 用于临时场景 使用一次即不用

var s struct {
	name string
	age  int
}

// 结构体是值类型
type person1 struct {
	name, gender string
}

func f1(x person1) {
	x.gender = "男"
}

// 指针引用地址

func f2(x *person1) {
	x.gender = "男"
}
